package cn.daniellee.plugin.lm.menu;

import cn.daniellee.plugin.lm.LotteryMaster;
import cn.daniellee.plugin.lm.core.PoolUsing;
import cn.daniellee.plugin.lm.model.PrizePool;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

public class LotteryMenu {

	public static Inventory generate(PrizePool prizePool, PoolUsing.UsingModel usingModel) {
		Inventory menu = Bukkit.createInventory(new LotteryMenuHolder(), usingModel == PoolUsing.UsingModel.LOTTERY ? 45 : 54, LotteryMaster.getInstance().getConfig().getString("menu.lottery.title", "&6&lPrize pool: {name}").replace("{name}", prizePool.getName()).replace("&", "§"));

		// 填充角
		int[] cornerPosition = new int[]{ 12, 14, 30, 32 };
		for (int i : cornerPosition) menu.setItem(i, Common.getCorner());
		// 填充边
		int[] borderPosition = new int[]{ 13, 21, 23, 31 };
		for (int i : borderPosition) menu.setItem(i, Common.getBorder());

		if (usingModel != PoolUsing.UsingModel.LOTTERY) {
			cornerPosition = new int[]{ 45, 49, 53 };
			for (int i : cornerPosition) menu.setItem(i, Common.getCorner());
			// 填充边
			borderPosition = new int[]{ 47, 51 };
			for (int i : borderPosition) menu.setItem(i, Common.getBorder());
		}


		return menu;
	}

	public static class LotteryMenuHolder implements InventoryHolder {
		@Override
		public Inventory getInventory() {
			return Bukkit.createInventory(null, 54);
		}
	}
}
